<template>
	<div id="app"  v-cloak>
		<keep-alive>
			<router-view ></router-view>
		</keep-alive>
	</div>
</template>

<script>
	import { mapActions, mapState } from 'vuex'
	export default {
        name: 'app',
		data() {
			return {
				pz: {
					appId: '',
				},
			}
		},
		computed: mapState([
			'appConfig',
		]),
		methods: {
			...mapActions([
				'setConfig',
			]),
			config: function(obj) {
				var config = window.getConfig();
				 if(this.appConfig.appId == null && config != null) {
					this.setConfig(config);
				}
			},
		},
		created(){
			window.getConfig = function(type) {
				var sessionConfig = JSON.parse(sessionStorage.getItem('a_config'));
				if(type == 1) {
					sessionConfig = sessionStorage.getItem('a_config');
				}
				return sessionConfig;
			};
			this.config(this.pz);
		},
		mounted() {
					/*设置返回页面滚动条位置*/
			window.setScrollTop = function(data) {
				self.setScrollTop(data)
			}
			/*得到页面滚动条位置*/
			window.getScrollTop = function(type) {
				return self.scrollTop[type];
			}
			var self = this;
			window.backtrack = function() {
				if(self.$route.path == '/') {
					window.history.back(-1);
				} else {
					window.history.back(-1);
				}
			}
			function checkIE() {
				console.log(1)
				return '-ms-scroll-limit' in document.documentElement.style && '-ms-ime-align' in document.documentElement.style
			}
			if(checkIE()) {
				console.log(2)
				window.addEventListener('hashchange', () => {
					var currentPath = window.location.hash.slice(1);
					if(this.$route.path !== currentPath) {
						console.log(3)
						this.$router.push(currentPath)
					}
				}, false)
			}
		}
	}
</script>

<style lang="scss">
    @import './styles/styles.scss';
	@import './styles/css.scss';	
</style>